package com.opNaga.bpmp.basicTest;

import com.opNaga.bpmp.swimlane.Lane;
import com.opNaga.bpmp.swimlane.Pool;
import org.junit.Assert;
import org.junit.Test;

/**
 * User: Junyi BEI
 * Date: 30/01/2012
 * Time: 12:46
 */
public class DestroyContainer {
  @Test
  public void destroyEmptyPool() {
    Pool pool = new Pool("pool");
    Assert.assertTrue(pool.destroy());
  }

  @Test
  public void destroyLaneInPool() {
    Pool pool = new Pool("pool");
    Lane lane = new Lane("lane");
    Assert.assertTrue(pool.addLane(lane));
    Assert.assertTrue(lane.destroy());
    pool.mute();
    lane.mute();
    Assert.assertFalse(pool.includes(lane));
    Assert.assertNull(lane.getParent());
  }

  @Test
  public void destroyPoolWithLanes() {
    Pool pool = new Pool("pool");
    Lane lane1 = new Lane("lane1");
    Lane lane2 = new Lane("lane2");
    Assert.assertTrue(pool.addLane(lane1));
    Assert.assertTrue(pool.addLane(lane2));
    Assert.assertTrue(pool.destroy());
    pool.mute();
    lane1.mute();
    lane2.mute();
    Assert.assertFalse(pool.includes(lane1));
    Assert.assertFalse(pool.includes(lane2));
    Assert.assertNull(lane1.getParent());
    Assert.assertNull(lane2.getParent());
  }
}
